import {  lazy } from 'react'
import { createBrowserRouter } from 'react-router-dom'
import App from '../App'

const Home = lazy(() => import('../pages/home/Index'))

const Index = lazy(() => import('../pages/index/Index'))
const Class = lazy(() => import('../pages/class/Index'))

const One = lazy(()=>import('../pages/class/one/Index'))
const Two = lazy(()=>import('../pages/class/two/Index'))

export const homeRouter = [
    {
        path: '/home/index',
        element: <Index></Index>,
        title: '首页'
    },
    {
        path: '/home/class',
        element: <Class></Class>,
        title: '分类',
        children:[
            {
                path:'/home/class/one/index',
                element:<One></One>,
                title:'一级分类'
            },
            {
                path:'/home/class/two/index',
                element:<Two></Two>,
                title:'二级分类'
            }
        ]
    }
]


const router = createBrowserRouter([
    {
        path: '/',
        element: <App></App>,
        children: [
            {
                index: true,
                element: <Home></Home>
            },
            {
                path: '/home',
                element: <Home></Home>,
                children: homeRouter
            }
        ]
    }
])
export default router